import sleekxmpp
import logging
class SendMsg(sleekxmpp.ClientXMPP):
    def __init__(self, recipient, msg, jid, password):
        super(SendMsg, self).__init__(jid, password)

        self.recipient = recipient
        self.msg = msg

        self.add_event_handler('session_start', self.start)

    def start(self, event):
        self.send_presence()
        self.get_roster()
        
        self.send_message(mto=self.recipient,
                          mbody=self.msg)
                          
        self.disconnect(wait=True)

def send_msg(jid, password, rcpt, msg):
    logging.disable(logging.WARNING)

    a = SendMsg(rcpt, msg, jid, password)
    if a.connect():
        a.process(block=True)       
    
    logging.disable(logging.NOTSET)
